var player = "<embed src=1.mp3 loop=-1>";
var items = ['1', '2', '3', '4', '5'];
var r = 1;
var jx = '特等奖';
var cf = '是';

function display() {
    document.getElementById("form1").style.display = "flex";
}

function setinfo() {
    r1 = document.form1.elements[0].value * 1;
    if (r1 != 0) {
        r = r1;
    }
    ;jx1 = document.form1.elements[1].value;
    if (jx1 != 0) {
        jx = jx1;
    }
    ;items1 = document.form1.elements[2].value.split(" ");
    if (items1 != 0) {
        items = items1;
    }
    ;cf1 = document.form1.elements[3].value;
    if (cf1 == '是' || cf1 == '否') {
        cf = cf1;
    }
    ;document.getElementById("form1").style.display = "none";
}

function Random() {
    var i = items.length, temp, num;
    var n = '';
    for (var j = 1; j < r + 1; j++) {
        num = Math.floor(Math.random() * (i - j + 1));
        temp = items[num];
        items[num] = items[i - j];
        items[i - j] = temp;
        n += "<p class='span' id='" + j + "'>" + items[i - j] + "</p>";
    }
    ;document.getElementById("random").innerHTML = n;
}

function choujiang() {
    var i = items.length;
    if (i < r) {
        alert("抽奖人数不足");
    } else if (document.getElementById("btn1").innerHTML == "开始抽奖") {
        document.getElementById("btn1").innerHTML = "停止抽奖";
        document.getElementById("player").innerHTML = player;
        fun = setInterval('Random()', 100);
    } else if (document.getElementById("btn1").innerHTML == "停止抽奖") {
        clearInterval(fun);
        document.getElementById("player").innerHTML = '';
        document.getElementById("btn1").innerHTML = "开始抽奖";
        var n2 = '';
        for (var j = 1; j < r + 1; j++) {
            document.getElementById('luckmen').innerHTML += "<p style='margin: 5px 5px 5px 60px;'>" + items[i - j] + "-------------------" + jx + "</p>";
        }
        ;
        if (cf == '否') {
            items.splice(i - r, r);
        }
    }
}